function InterceptorManager(this: any) {
  this.handlers = [];
}

InterceptorManager.prototype.use = function use(fulfilled: any, rejected: any) {
  this.handlers.push({
    fulfilled: fulfilled,
    rejected: rejected,
  });
  return this.handlers.length - 1;
};

InterceptorManager.prototype.eject = function eject(id: any) {
  if (this.handlers[id]) {
    this.handlers[id] = null;
  }
};

InterceptorManager.prototype.forEach = function forEach(fn: any) {
  this.handlers.forEach((h: any) => {
    if (h !== null) {
      fn(h);
    }
  });
};

export default InterceptorManager;
